﻿@using OBUCare.Web.Infrastructure;
@using OBUCare.Core.Models;
@using OBUCare.Core.BL;
@using OBUCare.Core.DataAccess;
@using OBUCare.Core.Common 
@model IList<View_PartsStock>

@{  
    this.Layout = "";
}



<div>



@(Html.Telerik().Grid<View_PartsStock>(Model)
            .Name("Grid")
            .DataKeys(keys => keys.Add(c => c.ID))
        //.Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
            .Resizable(resizing => resizing.Columns(true))
            .DataBinding(dataBinding => dataBinding
               .Server()
                )
            .Columns(columns =>
            {
                columns.Bound(o => o.ID).Title("序号").Width(100).Sortable(false);
                columns.Bound(o => o.PARTS_NAME).Width(150);
                columns.Bound(o => o.SUPPLIER_NAME).Width(100);
                columns.Bound(o => o.SPEC_NAME).Width(150);
                columns.Bound(o => o.Amount).Width(150);
                columns.Template(
                    @<text>
                        @Html.Telerik().IntegerTextBox().Name("Amount" + item.ID.ToString()).MinValue(0).MaxValue(item.Amount).Value(0).HtmlAttributes(new { @style = "width:100px;" }).InputHtmlAttributes(new { onchange = "javascript:sumCount(this);" }).ClientEvents(e => e.OnChange("sumCount"));                    
                    </text>
                ).Title("划拨数量");
                columns.Template(
                    @<text>                  
                        @Html.Hidden("objectInfo" + item.ID.ToText(), HttpUtility.UrlEncode(item.JsonSerializer()))                 
                    </text>
                    ).Title("对象系列化后的信息").Hidden();
            }).TableHtmlAttributes(new { style = "width:900px" })
                                   .Scrollable(scroll => scroll.Height(CommonStyleForUI.Grid_Height))
                                   .Footer(false)
                //                   .ClientEvents(events =>
                //{
                //    events.OnError("onError");
                //    events.OnDataBinding("onDataBinding");
                //})
                            )


</div>

<div>
    @Html.Hidden("ItemCount", Model.Count())
</div>